# author: alex
# time: 2022/4/25 20:43
"""
    文章测试
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.common.action_chains import ActionChains

option = webdriver.ChromeOptions()
option.binary_location = r'E:\Program Files\Google\Chrome\Application\chrome.exe'
bs = webdriver.Chrome(options=option)
bs.get('http://localhost:8082/log-reg')
bs.implicitly_wait(15)

bs.maximize_window()
time.sleep(1)
# 登录
username = bs.find_element(By.CSS_SELECTOR, '#form2 > span:nth-child(2) > input')
password = bs.find_element(By.CSS_SELECTOR, '#form2 > span:nth-child(3) > input')
username.send_keys('12345678901')
password.send_keys('123456')
btn = bs.find_element(By.CSS_SELECTOR, '#form2 > button')
btn.click()

canvas = bs.find_element(By.CSS_SELECTOR, 'body > canvas:nth-child(1)')
ActionChains(bs).move_to_element(canvas).move_by_offset(-475, -200).pause(2).click().perform()
time.sleep(1)
bs.find_element(By.CSS_SELECTOR, '#homePage > div.RightArctle.details > div.rightContent.list > button').click()
time.sleep(1)

title = bs.find_element(By.CSS_SELECTOR, '#write > div.HeadTitle > input[type=text]')
title.send_keys('测试标题')
# content=bs.find_element(By.CSS_SELECTOR,'#write > div.v-md-editor.v-md-editor--editable > div.v-md-editor__right-area > div.v-md-editor__main > div.v-md-editor__editor-wrapper > div > div > div.CodeMirror-scroll')
# content.click()

# content=bs.find_element(By.CSS_SELECTOR,'#write > div.v-md-editor.v-md-editor--editable > div.v-md-editor__right-area > div.v-md-editor__main > div.v-md-editor__editor-wrapper > div > div > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div:nth-child(1) > pre > span')
# bs.execute_script("document.querySelector(\"#write > div.v-md-editor.v-md-editor--editable > div.v-md-editor__right-area > div.v-md-editor__main > div.v-md-editor__editor-wrapper > div > div > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div > pre > span > span\").setAttribute(\"data-text\", true\");")
#
# bs.send_keys('测试内容12345678910111213141516171819')

# content=bs.find_element(By.CSS_SELECTOR,'#write > div.v-md-editor.v-md-editor--editable > div.v-md-editor__right-area > div.v-md-editor__main > div.v-md-editor__editor-wrapper > div > div > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div:nth-child(1) > pre > span')
bs.execute_script("document.querySelector('')")
# content.send_keys('测试内容12345678910111213141516171819')
